<%--
  Created by IntelliJ IDEA.
  User: imac
  Date: 2020/2/26
  Time: 5:17 下午
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.List" %>
<%@ page import="com.foreknow.model.Guestbook" %>
<%
    String path = request.getContextPath();
%>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/bootstrap.min.css">
</head>
<body>

<%--    <%=list.size()%>--%>
<div class="container">
    <table class="table table-hover">
        <tr>
            <td>id</td>
            <td>name</td>
            <td>phone</td>
            <td>email</td>
            <td>title</td>
            <td>content</td>
            <td>createtime</td>
            <td>操作</td>
        </tr>
        <%--如何才能获取到保存在服务器端的list集合--%>
        <%
            //request.getAttribute("list");获取保存在服务器端的数据
            //request.getAttribute("list");根据key值就可以获取到对应的value
            List<Object> list = (List<Object>)request.getAttribute("list");
            for(int i = 0;i<list.size();i++){
                Guestbook gb = (Guestbook) list.get(i);
        %>
        <tr>
            <td><%=gb.getId()%></td>
            <td><%=gb.getName()%></td>
            <td><%=gb.getPhone()%></td>
            <td><%=gb.getEmail()%></td>
            <td><%=gb.getTitle()%></td>
            <td><%=gb.getContent()%></td>
            <td><%=gb.getCreatedtime()%></td>
            <td>
                <a href="###" class="btn btn-primary">修改</a>
                <a href="<%=path%>/user/manager?id=<%=gb.getId()%>&q=delete" class="btn btn-danger">删除</a>
            </td>
        </tr>
        <%
            }
        %>
    </table>
</div>
</body>
</html>
resp.setContentType("text/html;charset=utf-8");
req.setCharacterEncoding("utf-8");
GuestbookService service = new GuestbookServiceImpl();

Guestbook gb = (Guestbook) req.getAttribute("gb");
boolean isRight = service.update(gb);
if (isRight){
req.getRequestDispatcher("/user/manager?q=list").forward(req,resp);
}